package com.zhong.beautifulimageapp.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.zhong.beautifulimageapp.utils.BaseFragments;

import java.util.List;

/**
 * ViewPager + Fragment的适配器
 * Created by 俊峰 on 2017/7/10.
 */

public class CommonFragmentAdapter extends FragmentPagerAdapter {

    private List<BaseFragments> mBaseFragmentsList;

    public CommonFragmentAdapter(FragmentManager fm, List<BaseFragments> baseFragments) {
        super(fm);
        mBaseFragmentsList = baseFragments;
    }

    @Override
    public Fragment getItem(int position) {
        return mBaseFragmentsList.get(position);
    }

    @Override
    public int getCount() {
        int count = 0;
        if (mBaseFragmentsList != null) {
            count = mBaseFragmentsList.size();
        }
        return count;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mBaseFragmentsList.get(position).getFragmentTitle();
    }
}
